package com.idp.common.util;

import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * 订单编号生成
 * @author xubinren
 * @version 1.0
 * @date 2018/3/6
 */
public class OrderCodeUtil {
	
	/**
	 * 生成订单编号:年月日时分秒
	 * 
	 * @return String
	 */
	public static String getOrderCode() {
		String orderCode = "MO";


		Date date = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
		String formatStr = sdf.format(date);

		orderCode += formatStr;


		Random random = new Random();
		String randomStr = "";
		for(int i = 0;i < 4;i++){
			randomStr += (Math.abs(random.nextInt())%10);
		}

		orderCode += randomStr;
		return orderCode;
	}

	public static void main(String[] args) {
		System.out.println(getOrderCode());
	}
}
